/*
APPENDIX FIGURE 2
Tests for non-linearities in the relationship between corporate PSL expsoure and access to PSL in non-mandate states. 
*/

cd "$exhibits_paths"

use "$data_path/main_analysis_file.dta", clear

* defining controls
	global demog i.gender i.race2_harm c.age_text_clean i.kids i.eslhome i.enrolled i.cohabstatus
	global work i.manager i.longwork_yrs i.union c.hourwage_clean c.usualhours_clean 
	global statechars c.unionmem_pc c.unemp_rate  c.minwage_state  	c.race_black c.race_amind c.race_asian c.race_pacisl c.race_other c.race_multi c.hispan c.age_u5 c.age_5to9 c.age_10to14 c.age_75to84 c.age_85plus c.female_pc c.educ_pc_hsgrad c.educ_pc_somecoll c.educ_pc_assoc c.educ_pc_bach c.educ_pc_grad
	global empchars i.shift_ind c.total_emps c.total_ests

*Puts percentage of firms workers with access to PSL into bins. 	
gen bin_emps_psl_place = 1 if pct_emps_psl_place>=0  & pct_emps_psl_place <15
replace bin_emps_psl_place = 2 if pct_emps_psl_place>=15 & pct_emps_psl_place <30
replace bin_emps_psl_place = 3 if pct_emps_psl_place>=30 & pct_emps_psl_place <45
replace bin_emps_psl_place = 4 if pct_emps_psl_place>=45 & pct_emps_psl_place <=100

*Labeling bins. 
lab def bins 1 "0-15%" 2 "15-30%" 3 "30-45%" 4 "45%+"
lab val bin_emps_psl_place bins

*Regression and margins plot. 
reg benefits_paidsick i.bin_emps_psl_place $demog $work i.statelist i.year##i.month if  psl_law_places_hybd == 0, vce(cluster statelist) 
margins bin_emps_psl_place
marginsplot, xtitle("% of Firm's Workers Exposed to PSL Mandate", size(medsmall)) ytitle("% of Workers in Non-PSL Mandate Places" "Reporting Access to Paid Sick", size(medsmall)) 	ylabel(0 "0%" .1 "10%" .2 "20%" .3 "30%" .4 "40%" .5 "50%" .6 "60%",labsize(medsmall)) title("")
	graph export "$exhibits_path/Appendix Figure 2.pdf", replace